package com.example.statemachine;

import com.example.statemachine.event.BaseEvent;
import com.example.statemachine.status.BaseStatus;

import java.util.Objects;

/**
 * @author renyitong
 * @version 1.0.0
 * @createTime 2024年01月11日
 * @Description 状态事件对，指定的状态只能接受指定的事件
 */
public class StatusEventPair<S extends BaseStatus, E extends BaseEvent> {

    /**
     * 指定的状态
     */
    private final S status;

    /**
     * 可接受的事件
     */
    private final E event;

    public StatusEventPair(S status, E event) {
        this.status = status;
        this.event = event;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        StatusEventPair<?, ?> that = (StatusEventPair<?, ?>) o;
        return Objects.equals(status, that.status) && Objects.equals(event, that.event);
    }

    @Override
    public int hashCode() {
        return Objects.hash(status, event);
    }

}
